<template>
  <el-form label-width="100px" class="demo-ruleForm">
    <el-form-item label="标题名称" prop="name">
      <el-input v-model="titlename"></el-input>
    </el-form-item>
    <el-form-item label="链接地址" prop="name">
      <el-input v-model="myhttp"></el-input>
      <span>（示列：http://www.baidu.com)</span>
    </el-form-item>

    <el-form-item label="图片上传">
      <el-upload
        class="upload-demo"
        action="/ads/AddAd"
        :limit="1"
        :on-exceed="handleExceed"
        :on-success="success"
        multiple
      >
        <el-button size="small" type="primary">点击上传</el-button>
        <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过2M</div>
      </el-upload>
    </el-form-item>

    <el-form-item label="详细介绍" prop="desc">
      <el-input type="textarea" v-model="msg"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="now">立即创建</el-button>
    </el-form-item>
  </el-form>
</template>
<script>
import Axios from "axios";
export default {
  data() {
    return {
      titlename: "",
      myhttp: "",
      msg: "",
      img: ""
    };
  },
  
  methods: {
   
    handleExceed() {
      alert("文件超出大小限制");
    },
    success(file) {
      this.img = file.file[0].path;
    },
    now() {
      
      const a = {
        add_name: this.titlename,
        add_img: this.img,
        add_http: this.myhttp,
        add_msg: this.msg
      };
      Axios.post("/ads/admsg", a).then((res)=>{
        // console.log(res.data);
        this.$router.push('/All/Ad')
      })
    }
  }
};
</script>

<style>
</style>